package client.controller;


import bjut.zrpc.core.optimization.annotation.ZRpcReference;
import bjut.zrpc.core.optimization.annotation.ZRpcSentinel;
import interfaces.HelloWordService;
import interfaces.PeopleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: zhuzhiming
 * @Date: 2022/5/9 12:44
 */
@RestController
public class HelloController {

    @ZRpcReference(group = "zhuzhiming-hello")
    HelloWordService helloWordService;

    // @ZRpcSentinel(sentinel = true,duration = 3000)
    //@ZRpcReference(group = "zhuzhiming-userinfo", version = "1", timeout = 100000, increase = 100, mock = false, mockMethod = "client.mock.MyMockMethod")
    @ZRpcReference(group = "zhuzhiming-userinfo")
    PeopleService peopleService;

    @GetMapping("/test")
    public String test() {
        long start = System.currentTimeMillis();
        System.out.println(start);
        String userInfo = peopleService.userInfo("zhuzhiming", 27);
        helloWordService.sayHello("zhuzhiming");
        System.out.println(userInfo);
        System.out.println(System.currentTimeMillis() - start);
        return userInfo;
    }

}
